/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package de.jadehs.cosima.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;

import de.jadehs.cosima.CosimaPackage;
import de.jadehs.cosima.Expression;
import de.jadehs.cosima.KleeneExpression;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Kleene Expression</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.jadehs.cosima.impl.KleeneExpressionImpl#getChildExpression <em>Child Expression</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class KleeneExpressionImpl extends ExpressionImpl implements KleeneExpression {
	/**
	 * The cached value of the '{@link #getChildExpression() <em>Child Expression</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getChildExpression()
	 * @generated
	 * @ordered
	 */
	protected Expression childExpression;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected KleeneExpressionImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return CosimaPackage.Literals.KLEENE_EXPRESSION;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Expression getChildExpression() {
		return childExpression;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetChildExpression(Expression newChildExpression, NotificationChain msgs) {
		Expression oldChildExpression = childExpression;
		childExpression = newChildExpression;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CosimaPackage.KLEENE_EXPRESSION__CHILD_EXPRESSION, oldChildExpression, newChildExpression);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setChildExpression(Expression newChildExpression) {
		if (newChildExpression != childExpression) {
			NotificationChain msgs = null;
			if (childExpression != null)
				msgs = ((InternalEObject)childExpression).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CosimaPackage.KLEENE_EXPRESSION__CHILD_EXPRESSION, null, msgs);
			if (newChildExpression != null)
				msgs = ((InternalEObject)newChildExpression).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CosimaPackage.KLEENE_EXPRESSION__CHILD_EXPRESSION, null, msgs);
			msgs = basicSetChildExpression(newChildExpression, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, CosimaPackage.KLEENE_EXPRESSION__CHILD_EXPRESSION, newChildExpression, newChildExpression));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case CosimaPackage.KLEENE_EXPRESSION__CHILD_EXPRESSION:
				return basicSetChildExpression(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case CosimaPackage.KLEENE_EXPRESSION__CHILD_EXPRESSION:
				return getChildExpression();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case CosimaPackage.KLEENE_EXPRESSION__CHILD_EXPRESSION:
				setChildExpression((Expression)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case CosimaPackage.KLEENE_EXPRESSION__CHILD_EXPRESSION:
				setChildExpression((Expression)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case CosimaPackage.KLEENE_EXPRESSION__CHILD_EXPRESSION:
				return childExpression != null;
		}
		return super.eIsSet(featureID);
	}

} //KleeneExpressionImpl
